//    Copyright (C) Kherty.  All rights reserved.
using System;
using OpenLS.Core.Serialization;
using OpenLS.Vml.Serialization;

namespace OpenLS.Vml.Drawing
{
    class StrokeChild : IOfficeXmlSerializableAs

    {
        private Ext? _ext;
        private bool? _on;
        private string _weight;
        private string _color;
        private string _color2;
        private string _opacity;
        private StrokeLineStyle? _linestyle;
        private double? _miterlimit;
        private StrokeJoinStyle? _joinstyle;
        private StrokeEndCap? _endcap;
        private string _dashstyle;
        private bool? _insetpen;
        private Vml.FillType? _filltype;
        private string _src;
        private ImageAspect? _imageaspect;
        private string _imagesize;
        private bool? _imagealignshape;
        private StrokeArrowType? _startarrow;
        private StrokeArrowWidth? _startarrowwidth;
        private StrokeArrowLength? _startarrowlength;
        private StrokeArrowType? _endarrow;
        private StrokeArrowWidth? _endarrowwidth;
        private StrokeArrowLength? _endarrowlength;
        private string _href;
        private string _althref;
        private string _title;
        private bool? _forcedash;


        public void ReadXmlAs(string name, ReadContext context)
        {
            using (var c = context.Read(name))
            {
                _ext = c.GetOptionalEnum<Ext>(VmlConstants.VmlNamespace + "ext");
                _on = c.GetOptionalBoolean("on");
                _weight = c.GetOptionalString("weight");
                _color = c.GetOptionalString("color");
                _color2 = c.GetOptionalString("color2");
                _opacity = c.GetOptionalString("opacity");
                _linestyle = c.GetOptionalEnum<StrokeLineStyle>("linestyle");
                _miterlimit = c.GetOptionalDouble("miterlimit");
                _joinstyle = c.GetOptionalEnum<StrokeJoinStyle>("joinstyle");
                _endcap = c.GetOptionalEnum<StrokeEndCap>("endcap");
                _dashstyle = c.GetOptionalString("dashstyle");
                _insetpen = c.GetOptionalBoolean("insetpen");
                _filltype = c.GetOptionalEnum<Vml.FillType>("filltype");
                _src = c.GetOptionalString("src");
                _imageaspect = c.GetOptionalEnum<ImageAspect>("imageaspect");
                _imagesize = c.GetOptionalString("imagesize");
                _imagealignshape = c.GetOptionalBoolean("imagealignshape");
                _startarrow = c.GetOptionalEnum<StrokeArrowType>(VmlConstants.VmlNamespace + "startarrow");
                _startarrowwidth = c.GetOptionalEnum<StrokeArrowWidth>(VmlConstants.VmlNamespace + "startarrowwidth");
                _startarrowlength = c.GetOptionalEnum<StrokeArrowLength>(VmlConstants.VmlNamespace + "startarrowlength");
                _endarrow = c.GetOptionalEnum<StrokeArrowType>(VmlConstants.VmlNamespace + "endarrow");
                _endarrowwidth = c.GetOptionalEnum<StrokeArrowWidth>(VmlConstants.VmlNamespace + "endarrowwidth");
                _endarrowlength = c.GetOptionalEnum<StrokeArrowLength>(VmlConstants.VmlNamespace + "endarrowlength");
                _href = c.GetOptionalString("href");
                _althref = c.GetOptionalString("althref");
                _title = c.GetOptionalString("title");
                _forcedash = c.GetOptionalBoolean("forcedash");
            }

        }

        public void WriteXmlAs(string name, WriteContext context)
        {
            using (var c = context.Write(name))
            {
                c.SetOptionalEnum(VmlConstants.VmlNamespace + "ext", _ext);
                c.SetOptionalBoolean("on", _on);
                c.SetOptionalString("weight", _weight);
                c.SetOptionalString("color", _color);
                c.SetOptionalString("color2", _color2);
                c.SetOptionalString("opacity", _opacity);
                c.SetOptionalEnum("linestyle", _linestyle);
                c.SetOptionalDouble("miterlimit", _miterlimit);
                c.SetOptionalEnum("joinstyle", _joinstyle);
                c.SetOptionalEnum("endcap", _endcap);
                c.SetOptionalString("dashstyle", _dashstyle );
                c.SetOptionalBoolean("insetpen", _insetpen );
                c.SetOptionalEnum("filltype", _filltype );
                c.SetOptionalString("src", _src );
                c.SetOptionalEnum("imageaspect", _imageaspect );
                c.SetOptionalString("imagesize", _imagesize );
                c.SetOptionalBoolean("imagealignshape", _imagealignshape );
                c.SetOptionalEnum(VmlConstants.VmlNamespace + "startarrow", _startarrow );
                c.SetOptionalEnum(VmlConstants.VmlNamespace + "startarrowwidth", _startarrowwidth );
                c.SetOptionalEnum(VmlConstants.VmlNamespace + "startarrowlength", _startarrowlength );
                c.SetOptionalEnum(VmlConstants.VmlNamespace + "endarrow", _endarrow );
                c.SetOptionalEnum(VmlConstants.VmlNamespace + "endarrowwidth", _endarrowwidth );
                c.SetOptionalEnum(VmlConstants.VmlNamespace + "endarrowlength", _endarrowlength );
                c.SetOptionalString("href", _href );
                c.SetOptionalString("althref", _althref );
                c.SetOptionalString("title", _title );
                c.SetOptionalBoolean("forcedash", _forcedash );
            }
        }
    }
}
